using System.Linq;
using System.Runtime.Serialization;
using Db4objects.Db4o;
using Db4objects.Db4o.Linq;

namespace SharedObjects
{
	[DataContract] public class SystemDirectory : EntityBase
	{
		[DataMember] public string Name { get; set; }
		//note: File system objects have their referential direction reversed.
		[DataMember]
		public SystemDirectory ParentDirectory { get; set; }

		//[DataMember]
		//public List<SystemDirectory> Children { get; set; }
		//[DataMember]
		//public List<SystemFile> Files { get; set; }
		public int GetUsedMemory(IObjectContainer db)
		{
			return (from SystemFile f in db where f.ParentId == Id && !f.IsDeleted select f.DisplaySize).Sum();
		}
	}
}